#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__

#include <iostream>
#include <string>
#include <unistd.h>


class channel
{
public:
    channel(int wfd,pid_t who)
    :_wfd(wfd),_who(who)
    {
        _name = "channel_" + std::to_string(wfd) + "_" + std::to_string(who);
    }
    int Wfd()
    {
        return _wfd;
    }

    std::string Name()
    {
        return _name;
    }

    pid_t Id()
    {
        return _who;
    }

    void Send(int cmd)
    {
        ::write(_wfd,&cmd,sizeof(cmd));
    }

    void Close()
    {
        ::close(_wfd);
    }
    ~channel()
    {
        
    }
private:
    int _wfd;
    std::string _name;
    pid_t _who;
};






#endif